package common;

import java.awt.Color;
import java.awt.Component;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class ColorRowRenderer extends DefaultTableCellRenderer {
	@Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                                                   boolean hasFocus, int row, int column){
       // if (value instanceof String && column == 5) {
                row = table.convertRowIndexToModel(row);
                String s = table.getModel().getValueAt(row, 6).toString();
                
                if (s.equals("In Scadenza (O)")) 
                {
                    setBackground(Color.RED);
                }
                else if(s.equals("In Scadenza (F)"))
                {
                	setBackground(Color.YELLOW);
                }
                else 
                {
                    setForeground(null);
                }
                return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                /*
        } else {
            setForeground(null);
            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }*/
    }
}
